//表单对象构造函数
function FormDataFactory(keys: string[]): void {
  if(!keys || !keys.length) return null
  keys.forEach((key) => {
    this[key] = null
  })
}


//表单校验对象构造函数
type RuleItem = {
  type: 'input' | 'select',
  label: string,
  key: string,
  other?: object
}
function FormRulesFactory(rules: Array<RuleItem>): void {
  if(!rules || !rules.length) return null
  rules.forEach(rule => {
    this[rule.key] = [{required:true,message: `${rule.type ==='input' ? '请输入' : '请选择'}${rule.label}`,trigger:['blur','change'] }]
  })
}


export default {
  FormDataFactory,
  FormRulesFactory
}
